package car.aistar.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
/**
 * @ClassName ErrorConfig
 * @Description TODO 错误相应控制器
 * @Author laoxu
 * @Date 2020/10/22 20:45
 * Version 1.0
 **/

@Configuration
public class ErrorConfig implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/error/400");
        ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/400");
        ErrorPage errorPageBadResult = new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400");
        ErrorPage errorPageException = new ErrorPage(Exception.class, "/error/400");
        ErrorPage errorPageThrowable = new ErrorPage(Throwable.class, "/error/400");
        registry.addErrorPages(errorPage404, errorPage500, errorPageThrowable, errorPageException, errorPageBadResult);
    }
}
